package cn.zyg.feign;

import cn.zyg.domain.User;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class UserServiceFallbackFactory implements FallbackFactory<UserService> {
    @Override
    public UserService create(Throwable throwable) {
        // 打印错误
        throwable.printStackTrace();
        return new UserService() {
            @Override
            public User getUserById(Long id) {
                return new User(-1L,"触发熔断，稍后重试");
            }
        };
    }
}
